#pragma once

namespace Microsoft
{
   namespace VisualStudio
   {
      namespace CppUnitTestFramework
      {
         template<> 
         static std::wstring ToString<CString>(CString const & t) 
         { 
            RETURN_WIDE_STRING((LPCTSTR)t); 
         }

         template<>
         static std::wstring ToString<WORD>(WORD const & t)
         {
            RETURN_WIDE_STRING(t);
         }

      }
   }
}

class CFooObject : public CObject
{
public:
   int value;

   CFooObject(int const v): value(v) {}
};

class CBar
{
public:
   int value;

   CBar(int const v): value(v) {}
};

template <class A>
void TraceTest(A & arr, CString const & format)
{
   for(auto e : arr)
   {
      TRACE(format + L"\n", e);
   }
}

template <class A>
void TraceTestConst(A const & arr, CString const & format)
{
   for(auto const & e : arr)
   {
      TRACE(format + L"\n", e);
   }
}

template <class M>
void TraceTestMap(M & map, CString const & format)
{
   for(auto p : map)
   {
      TRACE(format + L"\n", p.key, p.value);
   }
}

template <class M>
void TraceTestConstMap(M const & map, CString const & format)
{
   for(auto const & p : map)
   {
      TRACE(format + L"\n", p.key, p.value);
   }
}

template <class A, typename T>
void TestNumeric(A & arr, std::vector<int> const & expected)
{
   auto i = 0;
   for(T& e : arr)
   {
      Assert::AreEqual<T>(e, (T)expected[i++]);
   }
}

template <typename A, typename T>
void TestNumericConst(A const & arr, std::vector<int> const & expected)
{
   auto i = 0;
   for(auto const & e : arr)
   {
      Assert::AreEqual<T>(e, (T)expected[i++]);
   }
}

template <typename T>
bool contains(std::vector<T> const & v, T const value)
{
   return std::find(std::begin(v), std::end(v), value) != std::end(v);
}

const std::vector<int> g_sample{1, 2, 10, 42, 255};
const std::vector<int> g_sample2{2, 4, 20, 84, 510};

const std::vector<CString> g_sample_str{L"one", L"two", L"three", L"four", L"five"};
const std::vector<CString> g_sample2_str{L"ONE", L"TWO", L"THREE", L"FOUR", L"FIVE"};

